﻿
namespace PMIS.BLL
{
	/// <summary>
	/// 单例泛型类
	/// </summary>
	/// <typeparam name="T">业务逻辑类</typeparam>
	public class Singleton<T> where T : BL_Base, new()
	{
		#region 单例
		/// <summary>
		/// 本类的实例
		/// </summary>
		private static T bl = default(T);
		/// <summary>
		/// 用于本类实现单例的Locker
		/// </summary>
		private static object locker = new object();

		/// <summary>
		/// 获取本类的实例
		/// </summary>
		/// <returns></returns>
		public static T GetInstance()
		{
			if (bl == null)
			{
				lock (locker)
				{
					if (bl == null)
						bl = new T();
				}
			}

			return bl;
		}
		#endregion
	}
}
